
#include <cstdio>
#include "Bulk.h"
#include "PieceGoods.h"
#include "Cart.h"

int main(int argc, char* argv[])
{
  // 创建容器商品
  Commodity* cart = new Cart("shopping cart", 0.0f);
  Commodity* bag1 = new Cart("bag 1", 0.5f);
  Commodity* bag2 = new Cart("bag 2", 0.5f);

  // 创建货物
  Commodity* c1 = new PieceGoods("washing powder", 30.0f);
  Commodity* c2 = new Bulk("apple", 3.0f, 10.0f);
  Commodity* c3 = new Bulk("snacks", 8.0f, 88.0f);
  Commodity* c4 = new PieceGoods("rice", 150.8f);
  Commodity* c5 = new Bulk("pork", 35.0f, 2.0f);

  // 货物装箱
  cart->Add(c1);
  bag1->Add(c2);
  bag1->Add(c3);
  bag2->Add(c4);
  bag2->Add(c5);
  bag1->Add(bag2);
  cart->Add(bag1);

  // 结账
  printf("-----------------------购物清单-----------------------\n");
  printf("%-20s|%-10s|%-10s|%-10s\n", "COMMODITY", "COUNT", "PRICE", "TOTAL");
  printf("%-42s|%-10.2f\n", "SUM", cart->CheckOut());

  delete cart;
  return 0;
}
